package com.test.webchat.Service.Impl;

import com.test.webchat.Mapper.MessageMapper;
import com.test.webchat.Pojo.Model.Message;
import com.test.webchat.Service.MessageService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;

    @Override
    public List<Message> getMessagesBySessionId(Integer sessionId) {
        List<Message> messagesBySessionId = messageMapper.getMessagesBySessionId(sessionId);
        Collections.reverse(messagesBySessionId);
        return messagesBySessionId;
    }
}
